describe("MoveConfirmController unit test", function(){

    var moveConfirmController = null;
    var objE = {errorCode:'code', errorMessage:'message'};

    beforeEach(function(){


        var t_alertCtrl = App.AlertController.create();
        var t_loadingCtrl = App.LoadingController.create();
        var t_moveHolderCtrl = App.MoveHolderController.create();
        App.MoveConfirmController.reopen({

            init:function(){
                this.set('controllers.alert', t_alertCtrl);
                this.set('controllers.loading', t_loadingCtrl);
                this.set('controllers.moveHolder', t_moveHolderCtrl);
            }
        });

        moveConfirmController = App.MoveConfirmController.create();
        moveConfirmController.confirmListViewData = Ember.Object.create({
            displayList: []
        });
    });
    describe("controller unit test", function(){

        it("prepareController unit test", function(){
            var transfer = App.OwnAccountTransfer.create();
            spyOn(App.getSession(),'getCurrentTransfer').andReturn(transfer);
            spyOn(App.getSession().getCurrentTransfer(), 'set');
            spyOn(moveConfirmController, 'set');

            moveConfirmController.prepareController();

            expect(App.getSession().getCurrentTransfer).toHaveBeenCalled();
            expect(transfer.moduleName).toBe('confirm');
            expect(moveConfirmController.set).toHaveBeenCalledWith('transfer', transfer);
        });

        it("continueAction", function(){
            var transfer = App.OwnAccountTransfer.create();
            spyOn(moveConfirmController, 'get').andReturn(transfer);
            spyOn(moveConfirmController, 'showLoading');
            spyOn(moveConfirmController, 'confirmTransferCallback');
            var transferResult = [];

            spyOn(App.api_transfer,'confirmTransfer').andCallFake(function(transfer, callback){
                callback(transferResult,objE);
            });

            moveConfirmController.continueAction();
            expect(moveConfirmController.showLoading).toHaveBeenCalled();
            expect(App.api_transfer.confirmTransfer).toHaveBeenCalled();
            expect(moveConfirmController.confirmTransferCallback).toHaveBeenCalled();
        });

        it("confirmTransferCallback", function(){

            spyOn(moveConfirmController, 'hideLoading');
            //spyOn(moveConfirmController, 'resetProperties');
            spyOn(moveConfirmController, 'transitionTo');
            spyOn(moveConfirmController, 'get').andReturn({
                set: function(){
                    return  App.ConfirmOwnAccountTransfer.create() ;
                }
            });

            moveConfirmController.confirmTransferCallback();
            expect(moveConfirmController.hideLoading).toHaveBeenCalled();
            expect(moveConfirmController.get).toHaveBeenCalledWith('transfer')
            //expect(moveConfirmController.resetProperties).toHaveBeenCalled();
            expect(moveConfirmController.transitionTo).toHaveBeenCalledWith('move.summary');
        });

        it("resetProperties", function(){
            moveConfirmController.resetProperties();
        });
    });

    describe("showHideNotes unit test", function(){

        beforeEach(function(){
            spyOn(moveConfirmController, 'set');
            spyOn(moveConfirmController, 'toggleProperty');
        });
        afterEach(function(){
           expect(moveConfirmController.toggleProperty).toHaveBeenCalled();
            expect(moveConfirmController.get).toHaveBeenCalled();
        });


        it("enable showHideNotes", function(){
            spyOn(moveConfirmController, 'get').andReturn(false);
            moveConfirmController.showHideNotes();
            expect(moveConfirmController.set).toHaveBeenCalledWith("showHideText","Hide");
        });

        it("disable showHideNotes", function(){
            spyOn(moveConfirmController, 'get').andReturn(true);
            moveConfirmController.showHideNotes();
            expect(moveConfirmController.set).toHaveBeenCalledWith("showHideText","Show");
        });
    });

    describe("toPayee unit test", function(){

        it("toPayee not true", function(){
            var transfer = App.OwnAccountTransfer.create();
            expect(transfer.get('toPayee')).toBeFalsy();
        });

        it("toPayee - BillPayment  should be true", function(){
            var transfer = App.BillPayment.create();
            expect(transfer.get('toPayee')).toBeTruthy();
        });
    });

});